﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OnlineTestModel;
using OnlineTestBLL;
using FineUI;

namespace OnlineTestUI
{
    public partial class updatepassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["student"] != null)
            {
                
            }
            else
            {
                PageContext.Redirect("login.aspx");
            }
        }

        protected void BtAdd_Click(object sender, EventArgs e)
        {
            Students s = (Students)Session["student"];
            StudentsBLL sb = new StudentsBLL();
            s = sb.GetModel(s.Id);
            if (tbOldPassword.Text == s.PassWord)
            {
                if (tbOldPassword.Text == tbNewPassword.Text)
                {
                    Alert.Show("新密码和旧密码不能相同");
                }
                else
                {
                    s.PassWord = tbNewPassword.Text;
                    sb.Update(s);
                    Alert.Show("修改密码成功，请重新登录");
                    PageContext.Redirect("login.aspx","_parent");
                }
            }
            else
            {
                Alert.Show("对不起，旧密码错误");
            }
        }
    }
}